package thread5.TEST;

import javax.swing.plaf.SpinnerUI;

public class test4 {
    public static int a = 10;
    public static void main(String[] args) throws InterruptedException {
        int b = 10;
        Thread thread1 = new Thread(() -> {
            if (a == 10) {
                System.out.println("读取10");
                int c = 20;
            }
//            c = 30;//生命只存于所在最近{}中
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            if (a == 10) {
                System.out.println("读取10");
            }
//            b = 20;err
        });
        Thread thread2 = new Thread(() -> {
            a = 20;
        });
        thread1.start();
        thread2.start();
    }
}
